﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DOTNET101_ApplicationDomain
{
    class Program
    {
        static void Main()
        {
            // Create an Application Domain:
            System.AppDomain newDomain = System.AppDomain.CreateDomain("NewApplicationDomain");

            // Load the assembly into the current appdomain:
            // System.Reflection.Assembly newAssembly = System.Reflection.Assembly.LoadFrom(@"c:\DOTNET101-ApplicationDomain-RemoteObject.exe");

            // Instantiate RemoteObject:
            // newAssembly.CreateInstance("HelloWorldRemote.RemoteObject");

            // Load the assembly and call the default entry point:
            newDomain.ExecuteAssembly(@"c:\DOTNET101-ApplicationDomain-RemoteObject.exe");

            // Create an instance of RemoteObject:
            newDomain.CreateInstanceFrom(@"c:\DOTNET101-ApplicationDomain-RemoteObject.exe", "HelloWorldRemote.RemoteObject");

            // Load and execute an assembly:
            // newDomain.ExecuteAssembly(@"c:\HelloWorld.exe");

            // Unload the application domain:
            System.AppDomain.Unload(newDomain);
        }
    }
}
